package com.company.editortest;

import android.content.Context;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout;

public class NewEditText extends EditText {	
	private LinearLayout l;
	private EditText e;
	static boolean layoutState = false;
	int previousAction = -1;
	MotionEvent event_;
	InputMethodManager i;
	
	public NewEditText(Context context, LinearLayout layout, EditText edit, InputMethodManager imm) {
		super(context);
		l = layout;
		e = edit;	
		i = imm;
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
				
		int action = event.getAction();
		int actionMask = action & MotionEvent.ACTION_MASK;
		Log.d("mask action", Integer.toString(actionMask));
			if(event.getPointerCount() > 1){				
				if(event.getAction() == MotionEvent.ACTION_POINTER_UP){					
				if(layoutState == false){					
					l.setVisibility(View.VISIBLE);
					e.requestFocus();					
					layoutState = true;
					i.hideSoftInputFromWindow(this.getWindowToken(), 0);
				}
				else{
					if((event.getAction() == MotionEvent.ACTION_MOVE) || (event.getAction() == MotionEvent.ACTION_POINTER_UP))
					l.setVisibility(View.INVISIBLE);
					layoutState = false;
				}
				Log.d("touch", "multi touched");
			}
			
		}
		else{
			super.onTouchEvent(event);
			Log.d("touch", "single touched");			
		}
		return true;
	}
}
